package com.quotes.charts;

import java.awt.Color;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.xy.*;

import com.quotes.Parameters;
import com.quotes.datamodell.*;
import com.quotes.dates.TimeRange;
import com.quotes.indicators.*;

public class AdxChart extends LineChart
{
	private static final long serialVersionUID = 1L;
	private AdxIndicator indicator = null;
	
	public AdxChart(Quotes quotes, TimeRange range, int ticks) {
		super(quotes, range);
		
		this.indicator = new AdxIndicator(quotes, ticks);
		this.createChart(quotes);
	}
	
	protected XYDataset createXyDataset(Quotes product) {
		TimeSeriesCollection data = new TimeSeriesCollection();

    	TimeSeries adx = indicator.getAdx().extract(range);
    	data.addSeries(adx.convertToChartTimeSeries("ADX"));
    	
    	TimeSeries diMinus14 = indicator.getDiMinus().extract(range).multiplyWith(100);
    	data.addSeries(diMinus14.convertToChartTimeSeries("DI-14"));
    	
    	TimeSeries diPlus14 = indicator.getDiPlus().extract(range).multiplyWith(100);
    	data.addSeries(diPlus14.convertToChartTimeSeries("DI+14"));
    	
		return data;
	}
	
	@Override
	protected XYPlot manipulatePlot(XYPlot plot) {
		addVerticalMarker(plot, 30, Color.black);
		addVerticalMarker(plot, 25, Color.black);
		
		return plot;
	}
}
